const OWN_PAy = {
  CouponExchange: 'couponExchange', // 兑换券支付
  CouponReduction: 'couponReduction', // 优惠券支付
  FilmCard: 'filmCard', // 电影卡支付
  Integral: 'integral', // 积分支付
  Balance: 'balance', // 余额支付
  Juying: 'juying', // 聚影支付
  CouponGoodsReduction: 'couponGoodsReduction' // 卖品券支付
}
export default {
  data() {
    return {
      ownPayList: []
    }
  },
  methods: {
    setOwnPayList(value = this.query.ownPayStr) {
      let ownPayList = []
      if (typeof value === 'string') {
        ownPayList = value.split(',').filter((i) => i)
      } else if (value instanceof Array) {
        ownPayList = value.map((i) => i.key)
      }
      this.ownPayList = ownPayList
    },

    getOwnPayStr() {
      return this.ownPayList.join(',')
    },

    hasOwnPay() {
      const params = arguments
      for (let len = params.length; len--; ) {
        const key = params[len]
        const value = OWN_PAy[key] || ''
        const flag = this.ownPayList.includes(value)
        if (flag) {
          return flag
        }
      }
      return false
    },

    // type   film 影票 goods 卖品 mall 商品 vipcard 权益卡
    getOwnPayListApi(type) {
      uni.$api.channel.getOwnPayList({ type }).then((res) => {
        this.ownPayList = res.map((i) => i.key)
      })
    }
  }
}
